#include "main.h"

#include <stdint.h>
#include <stdio.h>
// #include <windows.h>
#include "../windows_service/os_ticket/os_ticket.h"
#include "../windows_service/tlog/tlog.h"
#include "TaiLingChargeProtocol.h"

#define TAG "MAIN"

#define SEND_BUFFER_SIZE 256
static uint8_t send_buffer[SEND_BUFFER_SIZE];

static void functional_test_log(void) { TLOGI(TAG, "functional_test_log\n"); }

static void buffer_dump(uint8_t* buffer, uint16_t size) {
  for (uint16_t i = 0; i < size; i++) {
    printf("0X%x ", buffer[i]);
  }
  printf("\n");
}

void handshake_test(void) {
  uint16 send_len       = 0;
  uint8  recv_buffer[9] = {0X46, 0XFF, 0X00, 0X02, 0X00, 0X00, 0X00, 0X00, 0X36};

  send_len = TaiLingCharge_Protocol_SendFrame_Process(send_buffer, SEND_BUFFER_SIZE);
  buffer_dump(send_buffer, send_len);

  TaiLingCharge_Protocol_RecvFrame_Process(recv_buffer, 9);
}

void main() {
  os_create_thread(handshake_test, 200);
  os_create_thread(functional_test_log, 1000);

  os_thread_start();
}